package com.szholly.data.general.interceptor;

import com.szholly.data.general.*;

/**
 * 类功能说明 定义编辑拦截基类
 */
public abstract class DbEditInterceptorClass extends DbInterceptorClass
		implements IDbEditInterceptor {

	/**
	 * 编辑操作前
	 * 
	 * @param table
	 * @param editEntitys
	 * @param editType
	 */
	public abstract void BeforeDbEditOption(ITable table, Object editEntitys,
			DbEditType editType);

	/**
	 * 编辑操作出错
	 * 
	 * @param table
	 * @param editEntitys
	 * @param editType
	 * @param ex
	 */
	public abstract void DbEditOptionException(ITable table,
			Object editEntitys, DbEditType editType, Exception ex);

	/**
	 * 编辑操作后
	 * 
	 * @param table
	 * @param editEntitys
	 * @param editType
	 */
	public abstract void AfterDbEditOption(ITable table, Object editEntitys,
			DbEditType editType);

	/**
	 * 编辑操作前
	 */
	public static void BeforeDbEditOptionEx(ITable table, Object editEntitys,
			DbEditType editType) {
		for (IDbEditInterceptor editItem : InterceptorRegister.dbEditInterceptor) {
			if (editItem != null && editItem.contains(table.getTableName())) {
				editItem.BeforeDbEditOption(table, editEntitys, editType);
			}
		}
	}

	/**
	 * 操作中出现了异常
	 */
	public static void DbEditOptionExceptionEx(ITable table,
			Object editEntitys, DbEditType editType, Exception ex) {
		for (IDbEditInterceptor editItem : InterceptorRegister.dbEditInterceptor) {
			if (editItem != null && editItem.contains(table.getTableName()))
				editItem.DbEditOptionException(table, editEntitys, editType, ex);
		}
	}

	/**
	 * 编辑操作后
	 */
	public static void AfterDbEditOptionEx(ITable table, Object editEntitys,
			DbEditType editType) {
		for (IDbEditInterceptor editItem : InterceptorRegister.dbEditInterceptor) {
			if (editItem != null && editItem.contains(table.getTableName())) {
				editItem.AfterDbEditOption(table, editEntitys, editType);
			}
		}
	}
}
